package pl.eskape.nawigacjapwr;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ListAdapter;
import android.widget.TextView;

import java.util.ArrayList;

/**
 * Created by Moominek on 15.09.13.
 */
public class Adapter_ListViewZBudynkami  extends BaseAdapter {

    private Context ctx;
    private ArrayList<Budynek> data;

    public Adapter_ListViewZBudynkami(Context ctx, ArrayList<Budynek> importeddata) {
        data = importeddata;
        this.ctx = ctx;
    }

    public int getCount() {
        return data.size();
    }

    public Budynek getItem(int position) {
        return data.get(position);
    }

    public long getItemId(int position) {
        return 0;
    }

    public View getView(int position, View convertView, ViewGroup parent) {

        if (convertView == null) {
            LayoutInflater inflater = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            convertView = inflater.inflate(R.layout.element_listview_z_budynkami, parent, false);
        }

        TextView tvNazwaBudynku = (TextView) convertView.findViewById(R.id.tv_nazwa_budynku);
        tvNazwaBudynku.setText(data.get(position).getNazwa());

        return convertView;
    }
}
